package com.nest.WorkNest;

import android.app.Application;
import android.content.Context;
import android.util.DisplayMetrics;
import android.widget.TabHost;

import com.nest.WorkNest.data.AppGlobal;
import com.nest.WorkNest.tools.FileUtils;
import com.orhanobut.logger.Logger;

public class MyApplication extends Application {

    public int tabHostId = 0;
    public TabHost tabHost;
    private static MyApplication mInstance;
    public int isApplication = 0;

    public static MyApplication getInstance() {
        return mInstance;
    }

    public Context context;

    @Override
    public void onCreate() {
        super.onCreate();
        mInstance = this;
        isApplication = 1;
        initApplication();
        Logger.init("WorkNest");       // default PRETTYLOGGER or use just init()
    }

    private void initApplication() {
        initScreen();
    }

    private void initScreen() {
        DisplayMetrics display = this.getResources().getDisplayMetrics();
        AppGlobal.screenWidth = display.widthPixels;
        AppGlobal.screenHeight = display.heightPixels;
        AppGlobal.screenDensityDpi = display.densityDpi;
        AppGlobal.screenDensityDpiRadio = display.density;
        AppGlobal.scaledDensity = display.scaledDensity;
        AppGlobal.externalFileDir = FileUtils.getExternalFilesDir(this).getAbsolutePath();
    }

    @Override
    public void onTerminate() {
        super.onTerminate();
        android.os.Process.killProcess(android.os.Process.myPid());
    }
}
